module.exports = class extends require('egg').Controller {
  async select() {
    const { ctx } = this;
    const { city, page } = ctx.request.body;
    const data = await ctx.service.post.select({ city, page });

    ctx.helper.res({ data });
  }
  async find() {
    const { ctx } = this;
    const { id } = ctx.request.body;
    const data = await ctx.service.post.find(id);

    ctx.helper.res({ data });
  }
  async unlock() {
    const { ctx } = this;
    const uid = ctx.helper.getUser();
    const data = await ctx.service.post.unlock({ uid, post_id: ctx.request.body.id });
    ctx.helper.res({ data });
  }
  async new() {
    const { ctx } = this;
    if (!ctx.request.body.contact) ctx.throw(400, '请务必填写联系方式');
    const uid = ctx.helper.getUser();
    const data = await ctx.service.post.new({ uid, ...ctx.request.body });
    ctx.helper.res({ data });
  }
};
